const BASE_URL = import.meta.env.VITE_PIC_URL

export function usePreview(){

    function previewImage(imgs: string[] | string, current: number = 0){
        const urls = (typeof imgs === 'string') ? [imgs] : [...imgs]
        uni.previewImage({
            urls: urls.map(item => item.startsWith('http') || item.startsWith('wxfile') ? item : `${BASE_URL}/browse?picfilename=${item}`),
            current
        })
    }

    return {
        previewImage
    }
}
